from fastapi import FastAPI
from fastapi.responses import RedirectResponse
from core.database import Base, create_engine  # 引入Base和engine

from routers import user, auth, department

app = FastAPI()
app.include_router(user.router)
app.include_router(auth.router)
app.include_router(department.router)

Base.metadata.create_all(bind=create_engine)  # 创建所有的表


@app.get("/", include_in_schema=False)
async def redirect_root_to_docs():
    return RedirectResponse("/docs")


if __name__ == "__main__":
    import uvicorn

    uvicorn.run(app, host="127.0.0.1", port=8080)
